﻿using System;
using System.Collections.Generic;
using System.Linq;
using NTTDATA.BEENChina.ResultCertification.PropertyGridUtil;
using NTTDATA.BEENChina.ResultCertification.PropertyGridUtil.CustomObject;

namespace NTTDATA.BEENChina.ResultCertification.Checker
{
    public class Verfity0304 : VerfityMulitResult
    {
   
        /// <summary>
        /// 2组录入结果 直接对比 一致false 不一致true
        /// </summary>
        /// <param name="result1"></param>
        /// <param name="entryCommon1"></param>
        /// <param name="result2"></param>
        /// <param name="entryCommon2"></param>
        /// <returns></returns>
        public override bool CheckResult(
            List<List<string>> result1, string entryCommon1, 
            List<List<string>> result2, string entryCommon2)
        {
            ////2个结果中如果有一个带问号 付签结果是20 不比较
            //if (entryCommon1.Equals("20") || entryCommon2.Equals("20"))
            //{
            //    return false;
            //}

            List<string[]> r1= result1.SelectMany(o => o.Select(p => p.Split(new char[] { '/' }))).ToList();
            List<string[]> r2 = result2.SelectMany(o => o.Select(p => p.Split(new char[] { '/' }))).ToList();
              
            for(int i=0;i<r1.Count() && i<r2.Count();i++)
            {
                for (int j = 0; j < r1[i].Count() && j < r2[i].Count(); j++)
                {
                    if (r1[i][j].Contains("?") || r2[i][j].Contains("?"))
                    {
                        continue;
                    }
                    //if( Enumerable.Any<CheckPair>(checkList,o => r1[i][j].Contains(o.Key) && r2[i][j].Contains(o.Value)
                    //                     || r1[i][j].Contains(o.Value) && r2[i][j].Contains(o.Key)))

                    //2个对比结果中如果有？
                    //去掉问号在比较
                   /* if (checkList.Any(o => checkPair(o,
                        r1[i][j].Replace("?",string.Empty)
                        , r2[i][j].Replace("?", string.Empty))))*/
                    //去掉问号有问题 ，恢复
                    if (CheckPair(r1[i][j], r2[i][j]))
                    {
                        return true;
                    }
                }
            }
            return false;
        }

        private bool CheckPair(  string result1, string result2)
        {
            return !result1.Equals(result2);
        }

       
    }
}